package com.qiaofang.common.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Date;

public class DateUtil {

    public static Date getNow() {
        return new Date();
    }

    public static Long getCurrentTime() {
        return System.currentTimeMillis();
    }

    public static Date minOfString(String date) {
        if (StringUtil.isBlank(date)) {
            return null;
        }
        LocalDateTime begin = LocalDateTime.of(LocalDate.parse(date), LocalTime.MIN);
        return Date.from(begin.atZone(ZoneId.systemDefault()).toInstant());
    }

    public static Date maxOfString(String date) {
        if (date == null) {
            return null;
        }
        LocalDateTime begin = LocalDateTime.of(LocalDate.parse(date), LocalTime.MAX);
        return Date.from(begin.atZone(ZoneId.systemDefault()).toInstant());
    }

    public static void main(String[] args) {
        System.out.println(DateUtil.minOfString("2019-07-15"));
        System.out.println(DateUtil.maxOfString("2019-07-15"));
    }
}
